//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

using System.Net;
using System.IO;

using Microsoft.Research.ScientificWorkflow;
using WorkflowData;

namespace Microsoft.Research.ScientificWorkflow.Activities
{
    [Name("Read NetCDF")]
    [Description("Read a NetCDF file into a hypercube")]
    [WorkflowCategory("NetCdf")]
    public partial class NetCDF_Read : System.Workflow.ComponentModel.Activity
    {
        #region Property Definitions
        // Required input property
        public static DependencyProperty FileNameProperty =
            DependencyProperty.Register("FileName", typeof(string), typeof(NetCDF_Read));
        // Output property
        public static DependencyProperty OutputHyperCubeProperty =
            DependencyProperty.Register("OutputHyperCube", typeof(HyperCube), typeof(NetCDF_Read));

        [RequiredInputParam]
        [Name("FileName")]
        [Description("File location to write data to")]
        public string FileName
        {
            get { return ((string)(base.GetValue(NetCDF_Read.FileNameProperty))); }
            set { base.SetValue(NetCDF_Read.FileNameProperty, value); }
        }

        [OutputParam]
        [Name("Output HyperCube", "Output")]
        [Description("The resulting filtered HyperCube data")]
        public HyperCube OutputHyperCube
        {
            get { return ((HyperCube)(base.GetValue(NetCDF_Read.OutputHyperCubeProperty))); }
            set { base.SetValue(NetCDF_Read.OutputHyperCubeProperty, value); }
        }
        #endregion

        public NetCDF_Read()
		{
			//InitializeComponent();
		}

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            Console.WriteLine("Reading NetCDF file into hypercube.");

            HyperCubeSchema newSchema = new HyperCubeSchema(1);
            newSchema.SetName(0, "Temperature");
            double tmp = 0.0;
            newSchema.SetType(0, tmp.GetType());

            HyperCube result = new HyperCube(newSchema, 5, 5, 5, 5);

            OutputHyperCube = result;

            return base.Execute(executionContext);
        }
	}
}
